/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.entity;

import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.Entity;
import org.ipti.br.tag.util.EncryptionUtil;

/**
 *
 * @author root
 */
@Entity
public class AdditionalInfoType extends AbstractEntity{

    @Column(nullable=false, length=5)
    private String acronym;
    
    @Column(nullable=false, length=50)
    private String name;
    
    @Column(length=80)
    private String mask;

    private short precedence;
    
    private boolean compulsory;
    
    public AdditionalInfoType() {
    }

    @Override
    public void generateHash(){
        if(getId() == null){
            String hash = "" + this.getAcronym()
                    + this.getName()
                    + this.getMask();
            this.setId(Long.valueOf(EncryptionUtil.encrypt(hash).hashCode()));
        }
    }

    public AdditionalInfoType(String acronym, String name, String mask, short precedence) {
        this.acronym = acronym;
        this.name = name;
        this.mask = mask;
        this.precedence = precedence;
    }

    public AdditionalInfoType(String acronym, String name, String mask, short precedence, Calendar lastModified, Long serialNumber, boolean compulsory) {
        this.acronym = acronym;
        this.name = name;
        this.mask = mask;
        this.precedence = precedence;
        this.compulsory = compulsory;
    }
    
    public String getAcronym() {
        return acronym;
    }

    public void setAcronym(String acronym) {
        this.acronym = acronym;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMask() {
        return mask;
    }

    public void setMask(String mask) {
        this.mask = mask;
    }

    public short getPrecedence() {
        return precedence;
    }

    public void setPrecedence(short precedence) {
        this.precedence = precedence;
    }

    public boolean isCompulsory() {
        return compulsory;
    }

    public void setCompulsory(boolean compulsory) {
        this.compulsory = compulsory;
    }
    
}
